#ifndef MODULE_FACTORY_H
#define MODULE_FACTORY_H
#include <stdio.h>

#define ECU_PN_MAX        31
#define ECU_RANDOM_MAX    31
#define ECU_IAP_MAX       31
#define FLASH_SUBG_SN_MAX   31
#if PN_LEN > ECU_PN_MAX
    #error "PN_LEN larger than ECU_PN_MAX"
#endif
#if IAPKEY_LEN > ECU_IAP_MAX
    #error "IAPKEY_LEN larger than ECU_IAP_MAX"
#endif
#if RANDOM_DATA_LEN > ECU_RANDOM_MAX
    #error "RANDOM_DATA_LEN larger than ECU_RANDOM_MAX"
#endif
#if SUBG_SN_LEN > FLASH_SUBG_SN_MAX
    #error "SUBG_SN_LEN larger than FLASH_SUBG_SN_MAX"
#endif
enum
{
	FACTORY_TYPE_BOARDCHECK = 0,		//AT cmd
	FACTORY_TYPE_FACCHECK,				//PDA or After-sale
};

typedef struct {
    struct {
        volatile uint8_t enable:1;
        volatile uint8_t result:1;

        uint8_t comType;
        uint8_t sendCnt;
        uint8_t ackCnt;
    } comTest;

    struct {
        uint8_t enable:1;
        uint8_t mode;

        uint8_t red;
        uint8_t green;
        uint8_t blue;
    } colarLed;

    struct {
        uint8_t enable:1;
        uint8_t mode;
    } buzzer;

}BoardCheckData_st;

//#pragma pack(4)
typedef struct{ //__packed 
    uint8_t pnArray[ECU_PN_MAX+1];
    uint8_t randomNumArray[ECU_RANDOM_MAX+1];
    uint8_t iapKeyArray[ECU_IAP_MAX+1];
}FactoryDataNessary_st;

typedef enum
{
    BOARD_NUM_VA = 0,
    BOARD_NUM_VB,
    BOARD_NUM_VC,

    BOARD_NUM_MAX,
}en_BoardNum;

extern BoardCheckData_st board_check_data;
extern FactoryDataNessary_st g_factory_nessary;

void board_id_init(void);
uint8_t board_id_get(void);
en_BoardNum board_num_get(void);
uint8_t get_factory_status(uint8_t type);
void set_factory_status(uint8_t type, uint8_t value);
int8_t factory_data_init(void);
uint32_t getbootloaderversion(void);

#endif


